import collections
class Solution(object):
    def maximumDetonation(self, bombs):
        n = len(bombs)
        d = collections.defaultdict(set)
        for i in range(n):
            x1, y1, r1 = bombs[i]
            for j in range(n):
                if i != j:
                    x2, y2, r2 = bombs[j]
                    if (x2 - x1) ** 2 + (y2 - y1) ** 2 <= r1 ** 2:
                        d[i].add(j)
        def dfs(x):
            if not d[x]:
                return 1
            else:
                ans = 1
                for y in d[x]:
                    if not used[y]:
                        used[y] = 1
                        ans += dfs(y)
                return ans
        max_b = 0
        for i in range(n):
            used = [0] * n
            used[i] = 1
            max_b = max(max_b, dfs(i))
        return max_b

data = Solution()
# bombs = [[54, 95, 4], [99, 46, 3], [29, 21, 3], [96, 72, 8], [49, 43, 3], [11, 20, 3], [2, 57, 1], [69, 51, 7],
#          [97, 1, 10], [85, 45, 2], [38, 47, 1], [83, 75, 3], [65, 59, 3], [33, 4, 1], [32, 10, 2], [20, 97, 8],
#          [35, 37, 3]]
# print(data.maximumDetonation(bombs))

bombs = [[2,1,3],[6,1,4]]
print(data.maximumDetonation(bombs))